package com.huiruan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huiruan.entity.Address;
import com.huiruan.service.AddressService;
import com.huiruan.mapper.AddressMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author CTL
* @description 针对表【address(收货地址表)】的数据库操作Service实现
* @createDate 2025-05-12 18:24:28
*/
@Service
@RequiredArgsConstructor
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address>
    implements AddressService{
    @Autowired
    private  final  AddressMapper addressMapper;
    @Override
    public List<Address> getList() {
        QueryWrapper<Address> queryWrapper = Wrappers.query();
        return addressMapper.selectList(queryWrapper);
    }

    @Override
    public int add(Address address) {
        return addressMapper.insert(address);
    }

    @Override
    public int update(Address address) {
        return addressMapper.updateById(address);
    }

    @Override
    public int deletebyId(String id) {
        return addressMapper.deleteById(id);
    }

    @Override
    public int setDefault(String id) {
        addressMapper.cancelDefault();
       int count = addressMapper.setDefault(id);
        return 0;
    }
}




